{% set pypi_name = 'python-masakariclient' %}
{% set upstream_version = upstream_version('6.2.1') %}
{% set rpm_release = '1' %}
{% set source = url_pypi() %}

%global oldpython python
Name:           {{ py2name() }}
Version:        {{ py2rpmversion() }}
Release:        {{ py2rpmrelease() }}
Epoch:          {{ epoch('python-masakariclient') }}
Summary:        Python API and CLI for OpenStack Masakari
License:        {{ license('Apache-2.0') }}
Group:          Development/Languages/Python
URL:            https://docs.openstack.org/{{ pypi_name }}
Source0:        {{ source }}
BuildRequires:  openstack-macros
BuildRequires:  {{ py3('PrettyTable') }}
BuildRequires:  {{ py3('ddt') }}
BuildRequires:  {{ py3('openstacksdk') }}
BuildRequires:  {{ py3('osc-lib') }}
BuildRequires:  {{ py3('oslo.serialization') }}
BuildRequires:  {{ py3('oslo.utils') }}
BuildRequires:  {{ py3('oslotest') }}
BuildRequires:  {{ py3('python-subunit') }}
BuildRequires:  {{ py3('requests-mock') }}
BuildRequires:  {{ py3('stestr') }}
BuildRequires:  {{ py3('testscenarios') }}
BuildRequires:  {{ py3('testtools') }}
BuildArch:      noarch

%description
Client library for Masakari built on the Masakari API. It provides a Python API
(the masakariclient module) and a command-line tool (masakari).

%package -n python3-masakariclient
Summary:        Python API and CLI for OpenStack Masakari
Requires:       {{ py3('openstacksdk') }}
Requires:       {{ py3('oslo.i18n') }}
Requires:       {{ py3('oslo.serialization') }}
Requires:       {{ py3('oslo.utils') }}
Requires:       {{ py3('pbr') }}
Conflicts:      %oldpython-masakariclient < %version

%description -n python3-masakariclient
Client library for Masakari built on the Masakari API. It provides a Python API
(the masakariclient module) and a command-line tool (masakari).

This package contains the Python 3.x module.

%package -n {{ pypi_name }}-doc
Summary:        Documentation for OpenStack Masakari API client libary
Group:          Documentation/HTML
BuildRequires:  {{ py3('Sphinx') }}
BuildRequires:  {{ py3('openstackdocstheme') }}
%if 0%{?suse_version}
Obsoletes:      %oldpython-masakariclient < %version
%endif

%description -n {{ pypi_name }}-doc
Client library for Masakari built on the Masakari API. It provides a Python API
(the masakariclient module) and a command-line tool (masakari).
This package contains the documentation.

%prep
%autosetup -p1 -n {{ pypi_name }}-%{version}
%py_req_cleanup

%build
%{py3_build}

# Build HTML docs and man page
PBR_VERSION={{ upstream_version }} %sphinx_build -b html doc/source doc/build/html
PBR_VERSION={{ upstream_version }} %sphinx_build -b man doc/source doc/build/man
rm -r doc/build/html/.{doctrees,buildinfo}

%install
%{py3_install}
# man pages
install -p -D -m 644 doc/build/man/python-masakariclient.1 %{buildroot}%{_mandir}/man1/python-masakariclient.1

%check
python3 -m stestr.cli run

%files -n python3-masakariclient
%license LICENSE
%{python3_sitelib}/masakariclient
%{python3_sitelib}/*.egg-info
%{_bindir}/masakari

%files -n {{ pypi_name }}-doc
%license LICENSE
%doc doc/build/html
%{_mandir}/man1/python-masakariclient.1.*

%changelog
